// new
// import { configureStore } from '@reduxjs/toolkit'

// export default configureStore({
//   reducer: {}
// })

// 1. 引入redux

import { createStore } from 'redux'
import {combineReducers} from "redux";
import { applyMiddleware, compose } from 'redux';

import CityReducer from './reducers/CityReducer';
import TabberReducer from './reducers/TabberReducer';

// const reducer = (prevState = {
//     show: true,
//     cityName: '北京'
// }, action) => {

//     let newState = { ...prevState }

//     switch (action.type) {
//         case 'hide-tabber':
//             newState.show = false
//             return newState;
//         case 'show-tabber':
//             newState.show = true
//             return newState;
//         case 'selectCity':
//             newState.cityName = action.query
//             return newState
//         default:
//             return prevState
//     }

// }
const reducer = combineReducers({
    CityReducer,
    TabberReducer
})


// const store = createStore(reducer)

const composeEnhancers = window.__REDUX_DEVTOOLS_EXTENSION_COMPOSE__ || compose;
const store = createStore(reducer, /* preloadedState, */ composeEnhancers())
/*
    store.dispatch
    store.subscribe
    store.getstate
*/
// function createchuckStore(reducer){
//     let list = []
//     let state = reducer(undefined, {})

//     function subscribe(callback){
//         list.push(callback)
//     }

//     function dispatch(action = {}){
//         state = reducer(state, action)
//         for(let i in list){
//             list[i] && list[i]()
//         }
//     }

//     function getState(){
//         return state
//     }
//     return {
//         dispatch,
//         subscribe,
//         getState
//     } 
// }

export default store